#ifndef GRIDMAP_H
#define GRIDMAP_H

#include <QWidget>
#include <QPushButton>
#include "qrviz.hpp"

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include "QVTKOpenGLNativeWidget.h"
#include <vtkGenericOpenGLRenderWindow.h>
#include <sensor_msgs/PointCloud2.h>
#include <nav_msgs/OccupancyGrid.h>
#include <QtWidgets/QDoubleSpinBox>
#include <QCheckBox>

class GridMapWidget : public QWidget
{
    Q_OBJECT
public:
   explicit GridMapWidget(QWidget *parent = nullptr);

public slots:
    void onOpenPCD();
    void onConvertPoint2Map();
    void onSaveMap();

private:
    void setupUI();
    void initialVtkWidget();


private:

    QRviz * m_rviz;
    QPushButton *m_btnSave;
    QPushButton *m_btnConvert;
    QPushButton *m_btnOpenPcd;

    QCheckBox *m_checkPoint2;
    QCheckBox *m_checkMap;

    QDoubleSpinBox  *m_spanMin;
    QDoubleSpinBox  *m_spanMax;


    boost::shared_ptr<pcl::visualization::PCLVisualizer> view;
    QVTKOpenGLNativeWidget *openGLWidget;
    pcl::PointCloud<pcl::PointXYZ>::Ptr m_cloud;

    sensor_msgs::PointCloud2 pc2;
    nav_msgs::OccupancyGrid m_msg;

    QString m_fileName;
};

#endif // GRIDMAP_H
